<script setup lang="ts">
// 获取屏幕边界到安全区域距离
const { safeAreaInsets } = uni.getSystemInfoSync()
// 订单选项
const orderTypes = [
  { type: 1, text: '待付款', icon: 'icon-currency' },
  { type: 2, text: '待发货', icon: 'icon-gift' },
  { type: 3, text: '待收货', icon: 'icon-check' },
  { type: 4, text: '待评价', icon: 'icon-comment' },
]
</script>

<template>
  <scroll-view class="viewport" scroll-y enable-back-to-top>
    <!-- 个人资料 -->
    <view class="profile" :style="{ paddingTop: safeAreaInsets!.top + 'px' }">
      <!-- 情况1：已登录 -->
      <view class="overview" v-if="false">
        <navigator url="/pagesMember/profile/profile" hover-class="none">
          <image
            class="avatar"
            mode="aspectFill"
            src="https://pcapi-xiaotuxian-front-devtest.itheima.net/miniapp/uploads/avatar_1.jpg"
          ></image>
        </navigator>
        <view class="meta">
          <view class="nickname"> 黑马程序员 </view>
          <navigator class="extra" url="/pagesMember/profile/profile" hover-class="none">
            <text class="update">更新头像昵称</text>
          </navigator>
        </view>
      </view>
      <!-- 情况2：未登录 -->
      <view class="overview" v-else>
        <navigator url="/pages/login/login" hover-class="none">
          <image
            class="avatar gray"
            mode="aspectFill"
            src="http://yjy-xiaotuxian-dev.oss-cn-beijing.aliyuncs.com/picture/2021-04-06/db628d42-88a7-46e7-abb8-659448c33081.png"
          ></image>
        </navigator>
        <view class="meta">
          <navigator url="/pages/login/login" hover-class="none" class="nickname">
            未登录
          </navigator>
          <view class="extra">
            <text class="tips">点击登录账号</text>
          </view>
        </view>
      </view>
      <navigator class="settings" url="/pagesMember/settings/settings" hover-class="none">
        设置
      </navigator>
    </view>
    <!-- 我的订单 -->
    <view class="orders">
      <view class="title">
        我的订单
        <navigator class="navigator" url="/pagesOrder/list/list?type=0" hover-class="none">
          查看全部订单<text class="icon-right"></text>
        </navigator>
      </view>
      <view class="section">
        <!-- 订单 -->
        <navigator
          v-for="item in orderTypes"
          :key="item.type"
          :class="item.icon"
          :url="`/pagesOrder/list/list?type=${item.type}`"
          class="navigator"
          hover-class="none"
        >
          {{ item.text }}
        </navigator>
        <!-- 客服 -->
        <view class="contact icon-handset"> 售后<button open-type="contact"></button> </view>
      </view>
    </view>
    <!-- 猜你喜欢 -->
    <view class="guess">
      <XtxGuess ref="guessRef" />
    </view>
  </scroll-view>
</template>

<style lang="scss">
.viewport {
  background-image: url(https://pcapi-xiaotuxian-front-devtest.itheima.net/miniapp/images/center_bg.png);
  background-repeat: no-repeat;
  background-size: 100%;

  // 头部用户区
  .profile {
    display: flex;
    justify-content: space-between;
    margin: 30rpx 50rpx 80rpx;
    color: #fff;
    .overview {
      display: flex;
      justify-content: start;
      align-items: center;
      font-size: 32rpx;
      font-weight: 500;
      //头像
      .avatar {
        width: 150rpx;
        height: 150rpx;
        border-radius: 50%;
      }
      //点击登录
      .meta {
        display: flex;
        flex-direction: column;
        padding-left: 25rpx;
        .nickname {
        }
        .extra {
          .tips {
            font-size: 28rpx;
          }
        }
      }
    }
    // 设置
    .settings {
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      height: 200rpx;
      font-size: 35rpx;
    }
  }

  // 头部订单区
  .orders {
    margin: 10rpx 30rpx 50rpx;
    background-color: #fff;
    border-radius: 10rpx;
    padding: 0 30rpx 50rpx;
    display: flex;
    flex-direction: column;
    .title {
      display: flex;
      justify-content: space-between;
      font-size: 32rpx;
      line-height: 4em;
      .navigator {
        font-size: 28rpx;
        color: #ccc;
      }
    }
    .section {
      display: flex;
      .navigator {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
      }
      .contact {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
      }
      button {
        width: 50rpx;
      }
    }
  }
}
</style>
